package neurons;

import java.util.HashSet;
import java.util.Set;

import appli.TrainerOr;

public class Out implements NeuronInterface, OutNeuronInterface {

	private Set<ConnectionInterface> incomingConnexions;
	private OutPutInterface outPut;

	public Out() {
		incomingConnexions = new HashSet<ConnectionInterface>();
	}

	@Override
	public void propagate(SignalInterface signal) {
		transmit(signal);
	}

	@Override
	public void adaptCoeff(ResultInterface result) {
		for (ConnectionInterface connection : incomingConnexions) {
			connection.getInNeuron().adaptCoeff(result);
		}
	}

	@Override
	public void sendConnectionTo(NeuronInterface targetNeuron) {
	}

	@Override
	public void acceptConnection(ConnectionInterface newConnection) {
		incomingConnexions.add(newConnection);
	}

	private void transmit(SignalInterface signal) {
		outPut.outSignalFormed(signal);
	}

	@Override
	public void setOutPut(OutPutInterface outPut) {
		this.outPut = outPut;

	}
}
